package com.manager.common.office.sax.thread;

import com.manager.common.office.sax.SAXExcelParseExecutor;
import org.apache.commons.collections.map.HashedMap;
import org.xml.sax.InputSource;

import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;

public class SAXParseCallable implements Callable<Map<String,List<?>>> {

    private Class<?> aClass;

    private String sheetName;

    private InputSource inputSource;

    private SAXExcelParseExecutor saxExcelParseExecutor;

    public SAXParseCallable(String sheetName,InputSource is,Class<?> claz,SAXExcelParseExecutor saxExcelParseExecutor){
        this.aClass = claz;
        this.inputSource = is;
        this.sheetName = sheetName;
        this.saxExcelParseExecutor = saxExcelParseExecutor;
    }

    @Override
    public Map<String,List<?>> call() throws Exception {
        Map<String,List<?>> map = new HashedMap();
        List<?> list = saxExcelParseExecutor.parseSheet(inputSource,aClass,sheetName);
        map.put(sheetName,list);
        return map;
    }
}
